﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Project
{
    public partial class Settings : Form
    {
        public Settings()
        {
            InitializeComponent();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void btn_update_Click(object sender, EventArgs e)
        {
            string start = "UPDATE tbl_employees SET";
            StringBuilder query = new StringBuilder();
            query.Append(start);
            if (chck_name.Checked)
                query.Append(" ,fld_firstName='" + txt_name.Text + "'");
            if (chck_lname.Checked)
                query.Append(" ,fld_lastName='" + txt_lname.Text + "'");
            if (chck_address.Checked)
                query.Append(" ,fld_address='" + txt_address.Text + "'");
            if (chck_phone.Checked)
                query.Append(" ,fld_phoneNumber='" + txt_phone.Text + "'");
            if (chck_password.Checked)
                query.Append(" ,fld_password='" + txt_password.Text + "'");
            query.Append(" WHERE fld_username LIKE '" + Login.username + "'");
            try
            {
                query.Remove(start.Length + 1, 1);
            }
            catch
            {
                MessageBox.Show("Please choose at least one field", "Error");
            }
            AdoHelper.ExecuteNonQuery(query.ToString());
        }

        private void btn_back_Click(object sender, EventArgs e)
        {
            
            this.Close();
        }
    }
}
